<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>轮播图</title>
    <link rel="stylesheet" href="../css/swiper.min.css">
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        .swiper-container {
            width: 800px;
            height: 300px;
        }

        #gallery .swiper-slide {
            line-height: 300px;
            text-align: center;
            font-size: 50px;
        }

        #thumbs .swiper-slide {
            line-height: 90px;
            text-align: center;
            font-size: 50px;
            height: 90px;
            opacity: 0.4;
            margin-right: 10px;
        }

        #thumbs .swiper-slide-thumb-active {
            opacity: 1;
        }
    </style>
</head>

<body>
    <div class="swiper-container swiper-container-initialized swiper-container-horizontal" id="gallery">
        <div class="swiper-wrapper">
            <div class="swiper-slide" style="background-color: blue;">Slide 1</div>
            <div class="swiper-slide" style="background-color: pink;">Slide 2</div>
            <div class="swiper-slide" style="background-color: green;">Slide 3</div>
        </div>
        <!-- 如果需要分页器 -->
        <div class="swiper-pagination"></div>

        <!-- 如果需要导航按钮 -->
        <div class="swiper-button-prev"></div>
        <div class="swiper-button-next"></div>

        <!-- 如果需要滚动条 -->
        <div class="swiper-scrollbar"></div>
    </div>
    <div class="swiper-container swiper-container-initialized swiper-container-horizontal swiper-container-thumbs"
        id="thumbs">
        <div class="swiper-wrapper">
            <div class="swiper-slide" style="background-color: blue;">Slide 1</div>
            <div class="swiper-slide" style="background-color: pink;">Slide 2</div>
            <div class="swiper-slide" style="background-color: green;">Slide 3</div>
        </div>
    </div>



    <script src="../js/swiper.min.js"></script>
    <script>
        var mySwiper = new Swiper('#gallery', {

            direction: 'horizontal', // 垂直切换选项
            loop: true, // 循环模式选项
            autoplay: {
                delay: 2000,
                stopOnLastSlide: false,
                disableOnInteraction: false,
            },

            // 如果需要分页器
            pagination: {
                el: '.swiper-pagination',
            },

            // 如果需要前进后退按钮
            navigation: {
                nextEl: '.swiper-button-next',
                prevEl: '.swiper-button-prev',
            },

            thumbs: {
                swiper: {
                    el: '#thumbs', //注意此处的设置方式
                    slidesPerView: 3,
                }
            }

            // 如果需要滚动条
            // scrollbar: {
            //     el: '.swiper-scrollbar',
            // },
        })    
    </script>
</body>

</html>